-
Notifications
You must be signed in to change notification settings - Fork 506
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enhance LogRecord::add_attributes interface to accept generic Iterables #1741
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1741 +/- ##
=======================================
+ Coverage 71.0% 71.4% +0.3%
=======================================
Files 135 136 +1
Lines 20751 20880 +129
=======================================
+ Hits 14746 14915 +169
+ Misses 6005 5965 -40 ☔ View full report in Codecov by Sentry. |
where | ||
I: IntoIterator<Item = (K, V)>, | ||
K: Into<Key>, | ||
V: Into<AnyValue>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not adding the default implementation to iteratively call add_attribute
in API, let SDK decide how to add the attributes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice. Always good to allow people bring their own types
@@ -26,7 +26,11 @@ pub trait LogRecord { | |||
fn set_body(&mut self, body: AnyValue); | |||
|
|||
/// Adds multiple attributes. | |||
fn add_attributes(&mut self, attributes: Vec<(Key, AnyValue)>); | |||
fn add_attributes<I, K, V>(&mut self, attributes: I) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would be good to leave a comment explaining that this API is designed to take ownership, unlike Metric APIs which just need slice/ref only to attributes.
Changes
Modify the
add_attributes
method in theLogRecord
trait to accept any type that implementsIntoIterator
, for better flexibility and usability. This change allows the method to handle a wider range of input types, including arrays, vectors, hashmap, and other custom collections.Existing:
PR:
Merge requirement checklist
CHANGELOG.md
files updated for non-trivial, user-facing changes